<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ncp.model.biz.comment.CommentCl"%>
<%@page import="com.ncp.model.entity.comment.ProductComment"%>
<%@page import="com.ncp.model.biz.comment.CommentScoCl"%>
<%@page import="com.ncp.model.entity.product.ProductDetailBean"%>
<%@page import="com.ncp.model.biz.product.ManageFrontProductBiz"%>
<%@page import="com.ncp.model.entity.cart.CartBean,com.ncp.model.entity.product.*"%>
<jsp:useBean id="cartbean" scope="session" class="com.ncp.model.entity.cart.CartBean"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.getAttribute("csc");
%>
<%
int id=1;
CommentBean cb = (CommentBean)request.getAttribute("cb");
ArrayList<ProductDetailBean> al =(ArrayList)request.getAttribute("listdetail");
ProductDetailBean pdb = (ProductDetailBean)al.get(0);
%>


<%
int nowPage=1;
int showPages=4;
id=Integer.parseInt((String)request.getAttribute("ProductID"));
ArrayList<ProductComment> list=(ArrayList)request.getAttribute("list");
CommentCl cc=new CommentCl();

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>产品详细</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<link href="css/common.css" type="text/css" rel="stylesheet" />
	<link href="css/detail.css" type="text/css" rel="stylesheet" />
	<link href="css/jquery.css" type="text/css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="css/cart.css">
	<script src="js/jq_1.js" type="text/javascript"></script>
	<script src="js/jq_2.js" type="text/javascript"></script>
	<script src="js/cart/cart.js" type="text/javascript" charset="UTF-8"></script>
	
	<script type="text/javascript">
	$(function() {
	   $("#tabs").tabs({
	    event: 'mouseover'
	   });
	});
	var xmlhttp;
	var s=1;
	window.onload=fnInit;
	function fnInit(){
		if(window.XMLHttpRequest){
			xmlhttp=new XMLHttpRequest();
		}
		else if(window.ActiveXObject){
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		
			var url="CommentScoServlet?ProductID=<%=id%>";
			xmlhttp.open("post",url,true);
			xmlhttp.onreadystatechange=function () {
				if(xmlhttp.readyState==4){
					
					if(xmlhttp.status==200){
						document.getElementById("tabs-2").innerHTML=xmlhttp.responseText;
					}
					else {
						alert("错误码"+xmlhttp.status);
					}
				}
			};
			
			xmlhttp.send(null);
	}
	
		function p(i){
			var url="CommentScoServlet?page="+i+"&ProductID=<%=id%>";
			s=i;
			xmlhttp.open("post",url,true);
			xmlhttp.onreadystatechange=function () {
				if(xmlhttp.readyState==4){
					
					if(xmlhttp.status==200){
						document.getElementById("tabs-2").innerHTML=xmlhttp.responseText;
					}
					else {
						alert("错误码"+xmlhttp.status);
					}
				}
			};
			
			xmlhttp.send(null);
	}
		
	function nextPage(){
		s=s+1;
			var url="CommentScoServlet?page="+s+"&ProductID=<%=id%>";
			
			xmlhttp.open("post",url,true);
			xmlhttp.onreadystatechange=function () {
				if(xmlhttp.readyState==4){
					if(xmlhttp.status==200){
						document.getElementById("tabs-2").innerHTML=xmlhttp.responseText;
					}
					else {
						alert("错误码"+xmlhttp.status);
					}
				}
			};
			
			xmlhttp.send(null);
	}
	function lastPage(){
		s=s-1;
		var url="CommentScoServlet?page="+s+"&ProductID=<%=id%>";
		
			xmlhttp.open("post",url,true);
			xmlhttp.onreadystatechange=function () {
				if(xmlhttp.readyState==4){
					if(xmlhttp.status==200){
						document.getElementById("tabs-2").innerHTML=xmlhttp.responseText;
					}
					else {
						alert("错误码"+xmlhttp.status);
					}
				}
			};
			
			xmlhttp.send(null);
	}
	function skip(){
		var url="CommentScoServlet?page="+document.getElementById("skip").value+"&ProductID=<%=id%>";
		
			xmlhttp.open("post",url,true);
			xmlhttp.onreadystatechange=function () {
				if(xmlhttp.readyState==4){
					if(xmlhttp.status==200){
						document.getElementById("tabs-2").innerHTML=xmlhttp.responseText;
					}
					else {
						alert("错误码"+xmlhttp.status);
					}
				}
			};
			
			xmlhttp.send(null);
		
	}

	</script>
 </head>
  
  <body>


<div id="allpage">
	<jsp:include flush="true" page="../index/head.jsp"></jsp:include>	
	<div id="main">
		<div id="sort">
			<div class="label">产品详情</div>
			<div class="green_bond"></div>
		</div>
		<div id="tab_page">
			<p class="name_font"><%=pdb.getProductName() %></p>

			<div class="exhibition left">
				<a href="#">
					<img src="<%=pdb.getProductImage() %>" style="width:260px; height:300px;" />
				</a>
			</div>
			
			<div class="introduction left">
				<p class="item">价&emsp;&emsp;格：&emsp;<span class="line_through"><%=pdb.getMarketPrice()%></>元</span></p>

				<p class="item">参加促销：&emsp;<span class="hot">今日促销</span>&emsp;<span class="red_big"><%=pdb.getRetailPrice()%>&nbsp;</span>元</p>
				<p class="item">所在地区：&emsp;福建泉州&emsp;|&emsp;至&nbsp;重庆&emsp;&emsp;快递：13.00元&emsp;EMS：22.00元</p>
				<p class="item">30天售出：&emsp;<span class="pink"><%=pdb.getSoldPNumber() %></span>件</p>

				<p class="item">评&emsp;&emsp;价：&emsp;
				<%for(int i=1;i<cb.getStar();i++){ %>
				<span class="star"></span>
				<%
				}
				 
				if((cb.getStar()*10)%10!=0){
				 if((cb.getStar()*10)%10<=3){
					 System.out.println(cb.getStar()%10);
					%>
					<span class="star1"></span>
					<%
					
				}
				else if(3<(cb.getStar()*10)%10&&(cb.getStar()*10)%10<8){
					%>
					<span class="star2"></span>
					<%
				}
					else if((cb.getStar()*10)%10>=8){
						%>
						<span class="star3"></span>
						<%
					}
				}
				%>
				
				<%=cb.getStar()%>分&emsp;|&emsp;<%=cb.getCommentNumber()%>条评价</p>
				
				<p class="item">会员折扣：&emsp;<%=pdb.getProductDiscount()%>&emsp;折</p><% %>
				<p class="item">付款方式：&emsp;<span class="credit">信用卡分期</span>&emsp;&emsp;快捷支付&emsp;&emsp;网银支付</p>

				<p class="item">购买数量：&emsp;
			<form name="form_test">
				
					<input type="hidden" name="allnum" id="allnum" value="<%=pdb.getCurrentPNumber()-pdb.getSoldPNumber() %>" />
			    	<input type="text" name="buynum" id="buynum" value="1" style="width:60px; border:1px solid #EEE;"/>件（库存<%=pdb.getCurrentPNumber()-pdb.getSoldPNumber() %>件）</p>
			         </form>
			        <input type="submit" value="" style="width:126px; height:35px; margin-top:10px; background:url(images/absulote/buy_now.png) no-repeat; cursor:pointer;" onclick="return(check())"/>
				    <input type="submit" value="" style="width:126px; height:35px; margin-top:10px; background:url(images/absulote/shopping_car.png) no-repeat; cursor:pointer;" onclick="addProduct('<%=pdb.getProductID()%>')" />
			   
			</div>
			
			
			<div style="clear:both"></div>
			
	

			<div id="tabs">
			   <ul>
				  <li><a style="cursor:pointer;" href="#tabs-1">产品详情</a></li>

				  <li><a style="cursor:pointer;" href="#tabs-2">评价详情</a></li>
			   </ul>
			   <div id="tabs-1">
				
					
					
					<div style="clear:both"></div>
					<div class="intro">
						
						<div class="box" style="text-align:center;">
							<p><%=pdb.getProductDescription() %></p>
						</div>
					</div>
					
			   </div>
			   <div id="tabs-2">
				</div>
			</div>			
		</div>
	</div>
	<!-- 购物车信息-->
    	<div id="shoppingcart"></div> 
    	
	<div id="slice">
	</div>
	
			<jsp:include flush="true" page="../index/foot.jsp"></jsp:include>
 </div>
</body>
</html>
